import service from "@/utils/request";


/**
 * 获取字典信息
 * @param params 传入参数
 * @returns 
 */
export function GetDictInfoByPage(params: any) {
  return service({
    url: "/itf/general/web/dict/info/page",
    method: "get",
    params
  })
}

/**
 * 新增字典信息
 * @param params 传入参数
 * @returns 
 */
export function AddDictInfo(data: any) {
  return service({
    url: "/itf/general/web/dict/info",
    method: "post",
    data
  })
}

/**
 * 修改字典信息By uuid
 * @param params 传入参数
 * @returns 
 */
export function UpdateDictInfoByUuid(uuid: any, data: any) {
  return service({
    url: `/itf/general/web/dict/info/uuid/${uuid}`,
    method: "put",
    data
  })
}

/**
 * 删除字典信息By uuid
 * @param params 传入参数
 * @returns 
 */
export function DeleteDictInfoByUuid(uuid: any) {
  return service({
    url: `/itf/general/web/dict/info/uuid/${uuid}`,
    method: "get",
  })
}

// 新增字典
export function AddDict(data: any) {
  return service({
    url: "/itf/general/web/dict/data",
    method: "post",
    data,
  });
}

// 编辑字典
export function EditDict(uuid: string, data: any) {
  return service({
    url: `/itf/general/web/dict/data/uuid/${uuid}`,
    method: "put",
    data,
  });
}

// 通过用户查询角色
export function QueryUserRoles(params: {}) {
  return service({
    url: `/itf/permission/web/user/role/relation`,
    method: "get",
    params,
  });
}
// 查询用户部门
export function QueryUserDepartment(params: {}) {
  return service({
    url: `/itf/permission/web/user/department/relation`,
    method: "get",
    params,
  });
}
// 查询角色
export function queryRolesLists(params: {}) {
  return service({
    url: `/itf/permission/web/sys_role/page`,
    method: "get",
    params,
  });
}
// 查询角色 不分页
export function queryRolesListsNoPage(params?: {}) {
  return service({
    url: `/itf/permission/web/sys_role`,
    method: "get",
    params,
  });
}
// 删除角色
export function DeleteRole(id: any) {
  return service({
    url: `/itf/permission/web/sys_role/${id}`,
    method: "delete",
  });
}
// 添加角色 
export function AddRole(data: {}) {
  return service({
    url: `/itf/permission/web/sys_role`,
    method: "post",
    data,
  });
}

// 查询所有权限
export function queryMenus(params?: {}) {
  return service({
    url: `/itf/permission/web/sys_menu`,
    method: "get",
    params,
  });
}
// 分页查询菜单
export function queryPageMenus(params: {}) {
  return service({
    url: `/itf/permission/web/sys_menu/page`,
    method: "get",
    params,
  });
}
// 分页查询部门列表
export function QueryDepartment(params: {}) {
  return service({
    url: `/itf/permission/web/department/page`,
    method: "get",
    params,
  });
}
// 查询通用字典列表- 不分页
export function QueryCommonDict(params: {}) {
  return service({
    url: `/itf/general/web/dict/data/page`,
    method: "get",
    params,
  });
}
// 查询角色权限
export function getRolePermission(data: {}) {
  return service({
    url: `/itf/permission/web/sys_role`,
    method: "post",
    data,
  });
}

// 新增角色菜单
export function addRoleMenus(data: {}) {
  return service({
    url: `/itf/permission/web/role/menu/relation/batch`,
    method: "post",
    data,
  });
}
// 查询角色权限
export function queryRolePersission(id: number) {
  return service({
    url: `/itf/permission/web/role/menu/relation/${id}`,
    method: "get",
  });
}

// 查询角色路由权限
export function GetRoleRouter(roleId: number) {
  return service({
    url: `/itf/permission/web/sys_menu/by_role_id/${roleId}`,
    method: "get",
  });
}

// 查询角色菜单权限
export function GetRoleMenus(params: {}) {
  return service({
    url: `/itf/permission/web/role/menu/relation`,
    method: "get",
    params
  });
}
// 启用角色
export function enabledRole(uuid: number) {
  return service({
    url: `/itf/permission/web/sys_role/enable/${uuid}`,
    method: "put",
  });
}
// 禁用角色
export function disabledRole(uuid: number) {
  return service({
    url: `/itf/permission/web/sys_role/disable/${uuid}`,
    method: "put",
  });
}

// 添加菜单
export function AddMenu(data: {}) {
  return service({
    url: `/itf/permission/web/sys_menu`,
    method: "post",
    data,
  });
}

// 编辑菜单
export function EditMenu(id: number, data: {}) {
  return service({
    url: `/itf/permission/web/sys_menu/uuid/${id}`,
    method: "put",
    data,
  });
}

// 添加部门
export function AddDepartment(data: {}) {
  return service({
    url: `/itf/permission/web/department`,
    method: "post",
    data,
  });
}
// 编辑部门
export function EditDepartment(uuid: number, data: object) {
  return service({
    url: `/itf/permission/web/department/uuid/${uuid}`,
    method: "put",
    data,
  });
}
// 删除部门
export function DeleteDepartment(uuid: number) {
  return service({
    url: `/itf/permission/web/department/uuid/${uuid}`,
    method: "delete",
  });
}
// 删除菜单
export function DeleteMenu(id: number) {
  return service({
    url: `/itf/permission/web/sys_menu/${id}`,
    method: "delete",
  });
}

// 根据登录用户查询列表
export function GetByLoginUser(params: {}) {
  return service({
    url: `/itf/permission/web/department/by_login_user`,
    method: "get",
    params
  });
}